#pragma once

#include "../_inc_util/UtilString.h"
#include "../_inc_app/CtrlButton.h"
#include "TimeZone.h"


// CWndGps

class CWndGps : public CWnd
{
	DECLARE_DYNAMIC(CWndGps)
public:
	enum _TAG_GPS_WND
	{
		GPS_HIDE = 0,
		GPS_SHOW_NORMAL,
		GPS_SHOW_LARGE
	};
private:
	enum 
	{
		START_END_TIME = 0,
		CURRENT_TIME,
		LATITUDE,
		LONGITUDE,
		EXT_END_TIME,
		DRIVING_SPEED,
		TEXT_COUNT
	};

private:
	CUtilString		m_UtilString;

	time_t			m_tStartTime;
	time_t			m_tEndTime;
	time_t			m_tGpsTime;
	float			m_fLatitude;
	float			m_fLongitude;	
	float			m_fSpeed;
	int				m_nUnit;

	CPen		m_penEdge;
	CBrush		m_brushBoard;
	CBrush		m_brushTextBk;
	CBrush		m_brushMark;

	BOOL		m_bPlayOn;
	int			m_nGpsWndMode;
	CCtrlButton		m_btnLarge;
	CCtrlButton		m_btnHide;
	CCtrlButton		m_btnNormal;

	CRect m_rtText[TEXT_COUNT];
	CFont m_fntText;
	CTimeZone m_TimeZone;
	CStringArray m_sarrText;

	DWORD m_dwColorBg;
	DWORD m_dwColorTextBg;
	DWORD m_dwColorText;
	DWORD m_dwColorMarker;
	DWORD m_dwColorTextTitle;

	int m_nMode;

	void UpdateButtonState();
	void TextOutGps(DWORD dwTextType);
	void LoadText();

public:
	CWndGps();
	virtual ~CWndGps();

	void SetPlayBlockTime(DWORD dwStart, DWORD dwEnd);
	void SetGpsInfo(DWORD dwTime, float fLatitude, float fLongitude);
	void SetGpsInfo(DWORD dwTime, float fLatitude, float fLongitude, float fSpeed, int nUnit);
	void UpdateGPS2();
	void UpdateGPS_Hide();
	void UpdateGPS_Normal();
	void UpdateGPS_Large(DWORD dwTextType);
	void SetPlayStatus(BOOL bPlayOn);// { m_bPlayOn = bPlayOn; };
	void SetWndSize(int nSizeMode) { m_nGpsWndMode = nSizeMode; };
	int GetWndSize() { return m_nGpsWndMode; };

	void SetSpeedUnit(int nUnit);

	void SetButtonState(BOOL bEnable);

	//view
	void UpdateGPS_Normal_m0();
	void UpdateGPS_Normal_m3();
	void UpdateGPS_Large_m0();
	void TextOutGps_m0(DWORD dwTextType);

	void UpdateGPS_Normal_m1();
	void UpdateGPS_Large_m1(DWORD dwTextType);
	void TextOutGps_m1(DWORD dwTextType);

	void RefreshLang();

protected:
	afx_msg void OnPaint();
	DECLARE_MESSAGE_MAP()

public:
	afx_msg long OnCtlMessage(UINT wParam, LONG lParam);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnDestroy();
};

extern CWndGps* g_pWndGps;

